<?php
$product_name = $product_type = $country_id = $price = $laboratory = $product_description = $short_desciption = $product_version = $product_keywords = '';
$count_arry = $price_array = $labor_array = $pid_array = $regular_price_array = array();
$sql = "SELECT tblproduct.*,tblproduct_in_pharmacy.* FROM tblproduct,tblproduct_in_pharmacy WHERE tblproduct.id=$id AND tblproduct.id = tblproduct_in_pharmacy.product_id ";
$result = mysql_query($sql);
$result1 = mysql_query($sql);
while ($row_c = mysql_fetch_assoc($result1)) {
    $price_array[] = $row_c['price'];
    $regular_price_array[] = $row_c['regular_price'];
    $labor_array[] = $row_c['laboratory'];
    $pid_array[] = $row_c['pid'];
    $pro_version = $row_c['product_version'];
    $contact_name = $row_c['contact_name'];
    $contact_email = $row_c['contact_email'];
    $contact_phone = $row_c['contact_phone'];
    $contact_address = $row_c['contact_address'];
    $productDescription = $row_c['product_description'];
}
$row = mysql_fetch_assoc($result);
//var_dump($row);
if (dbNumRows($result)) {
    extract($row);
}
?>
<div class="box">
    <div class="heading">
        <h1><img src="<?php echo base_url; ?>admin/templates/image/product.png" alt="" /> <?php echo $lang['PRODUCT']; ?></h1>
        <div class="buttons">
            <input class="button" type="submit" name="btnsubmit" value="Save" onclick="checkSellerform();" />
            <input class="button" type="button" value="<?php echo $lang['CANCEL']; ?>" onclick="window.location.href = 'index.php'" />
        </div>
    </div>
    <div class="content">
        <input type="hidden" name="hidid" value="<?php echo $id; ?>" />
        <div id="tabs" class="htabs">
            <a href="#tab-general"><?php echo $lang['PRODUCT']; ?></a>
            <a href="#tab-data"><?php echo $lang['MENU_CATEGORY']; ?></a>
            <a href="#tap-contact-detail">Contact Information</a>
        </div>
        <div id="tab-general">
            <table class="form">
                <tr>
                    <td> <?php echo $lang['PRO_NAME']; ?><span class="required">*</span></td>
                    <td><input type="text" name="new_proname" size="100" value="<?php echo stripslashes($product_name); ?>" /></td>                        
                </tr>
                <tr>
                    <td>Description</td>
                    <td><textarea name="txtdesc" id="txtdesc" style="height: 100px; margin: 0px 2px; width: 634px;"><?php echo stripslashes($productDescription); ?></textarea></td>
                </tr>
                <tr>
                    <td><?php echo $lang['CON_PRO_KEYWORD']; ?> </td>
                    <td><textarea name="txtkeywords" rows="5" cols="100"><?php echo stripslashes($product_keyword); ?></textarea></td>
                </tr>
                <?php
                $id = (int) $id;
                $selectImages = mysql_query("SELECT *FROM tblimage WHERE product_id='" . $id . "'");
                $i=0;
                while ($images_edit = mysql_fetch_object($selectImages)) {
                    $i++;
                    ?>
                    <tr>
                        <td><?php if($i==1) {echo $lang['IMG']; ?> <span style="color:red;">(Click On image for delete)</span><?php }?></td>
                        <td>
                            <div class="showcheckbox" style="float: left; margin-right: 35px;width:125;height:95;overflow:hidden;">
                                <input style="display: none" name="DelImage[]" type="checkbox" value="<?php echo $images_edit->id; ?>" id="<?php echo $images_edit->id; ?>" class="regular-checkbox"/>                           
                                <label for="<?php echo $images_edit->id; ?>"><img style="width:80px;" id="checkbox<?php echo $images_edit->id; ?>" src="<?php echo base_url . 'product/images/thumb/' . $images_edit->images; ?>"></label></div>
                            <script type="text/javascript">
                                $(function() {
                                    $("#<?php echo $images_edit->id; ?>").click(function() {
                                        var con = confirm("Are you sure to delete this image?");
                                        var commentContainer = $(this).parent();
                                        if (con == false) {
                                            $("#<?php echo $images_edit->id; ?>").attr("checked", false);
                                            return;
                                        } else if (con == true) {
                                            commentContainer.slideUp('slow', function() {
                                                $(this).hide();
                                            });
                                            return;
                                        }
                                    });
                                });
                            </script> 


                            
                           
                            <div class="imageitem"> </div>
                        </td>
                    </tr>
                <?php } ?>
                    <tr>
                        <td></td>
                        <td>
                            <div id="morefield"></div>
                        <div id="addfield" class="tablectrl_small bDefault" style="cursor: pointer;"><img src="<?php echo base_url;?>templates/image/addmore.png"/></div>
                        </td>
                    </tr>
            </table>
        </div>
        <div id="tab-data">
            <table class="form">
                <tr>
                    <td> <?php echo $lang['PRICE']; ?><span class="required">*</span></td>
                    <td>
                        <input type="hidden" name="selectCoun[]" value="38" />
                        <input type="text" name="price[]" value="<?php echo $price ?>" class="txtprice" />
                    </td>
                </tr>
                <tr>
                    <td> <?php echo $lang['CON_PRO_VERSION']; ?><span class="required">*</span></td>
                    <td>
                        <select name="selectProductVersion">
                            <option <?php echo (@$pro_version == 0) ? "selected" : ""; ?> value="0"><?php echo $lang['CON_PRO_VERSION_NEW']; ?></option>
                            <option <?php echo (@$pro_version == 1) ? "selected" : ""; ?> value="1"><?php echo $lang['CON_PRO_VERSION_USED']; ?></option>
                        </select>
                    </td>
                </tr>
                <tr>
                <tr>
                    <td colspan="2">
                        <?php
                        include(S_ROOT.'/includefiles/category.php');
                        ?>
                    </td>
                </tr>

            </table>
        </div>
        <div id="tap-contact-detail">
            <table class="form">
                <tr>
                    <td>Name:</td>
                    <td>
                        <input type="text" name="txtname" value="<?php echo (@$contact_name) ? $contact_name : ""; ?>" class="txtname" />
                    </td>
                </tr>
                <tr>
                    <td>Email:</td>
                    <td>
                        <input type="text" name="txtemail" value="<?php echo (@$contact_email) ? $contact_email : ""; ?>" class="txtemail" />
                    </td>
                    </td>
                </tr>
                <tr>
                <tr>
                    <td>Telephone:</td>
                    <td>
                        <input type="text" name="txttelephone" value="<?php echo (@$contact_phone) ? $contact_phone : ""; ?>" class="txttelephone" />
                    </td>
                </tr>
                <tr>
                    <td>Address:</td>
                    <td>
                        <input type="text" name="txtaddress" value="<?php echo (@$contact_address) ? $contact_address : ""; ?>" class="txtaddress" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<style>
    label {
        display: inline;
    }

    .regular-checkbox {
        display: none;
    }

    .regular-checkbox + label {
        background-color: #fafafa;
        border: 1px solid #eee;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05);
        padding: 9px;
        border-radius: 3px;
        display: inline-block;
        position: relative;
        margin: 10px 10px 0 0;
    }

    .regular-checkbox + label:active, .regular-checkbox:checked + label:active {
        box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px 1px 3px rgba(0,0,0,0.1);
    }

    .regular-checkbox:checked + label {
        background-color: #e9ecee;
        border: 1px solid #adb8c0;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05), inset 15px 10px -12px rgba(255,255,255,0.1);
        color: #99a1a7;
    }

    .regular-checkbox:checked + label:after {
        content: "\2718";
        background: none repeat scroll 0 0 #CCCCCC;
        color: #FF0000;
        font-size: 14px;
        left: 0;
        padding: -3px 0 0 0;
        padding-left: 5px;
        position: absolute;
        top: 0;
        width: 19px;
    }
</style>
